"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fixNumber = exports.Singleton = exports.ArrayMap = void 0;
var ArrayMap = /** @class */ (function () {
    function ArrayMap() {
        this.map = new Map();
        this.array = [];
        this.indexMap = new Map();
    }
    Object.defineProperty(ArrayMap.prototype, "length", {
        get: function () {
            return this.array.length;
        },
        enumerable: false,
        configurable: true
    });
    ArrayMap.prototype.get = function (key) {
        return this.map.get(key);
    };
    ArrayMap.prototype.set = function (key, value) {
        var index = this.indexMap.get(value);
        if (index == undefined) {
            this.array.push(value);
            this.indexMap.set(value, this.array.length - 1);
            this.map.set(key, value);
        }
    };
    ArrayMap.prototype.has = function (key) {
        return this.map.has(key);
    };
    ArrayMap.prototype.delete = function (key) {
        var value = this.map.get(key);
        if (value != null) {
            this.map.delete(key);
            var index = this.indexMap.get(value);
            this.array[index] = this.array[this.array.length - 1];
            this.indexMap.delete(value);
            var switchEcsEntity = this.array[index];
            if (switchEcsEntity !== value) {
                this.indexMap.set(value, index);
            }
            this.array.length -= 1;
        }
    };
    ArrayMap.prototype.forEach = function (callbackfn, thisArg) {
        this.array.forEach(callbackfn, thisArg);
    };
    ArrayMap.prototype.clear = function () {
        this.map.clear();
        this.indexMap.clear();
        this.array = [];
    };
    return ArrayMap;
}());
exports.ArrayMap = ArrayMap;
var Singleton = /** @class */ (function () {
    function Singleton() {
    }
    Singleton.instance = function () {
        if (!this._instance) {
            this._instance = new this();
        }
        var result = this._instance;
        return result;
    };
    return Singleton;
}());
exports.Singleton = Singleton;
function fixNumber(num, n) {
    if (n === void 0) { n = 10; }
    return Math.round(num * Math.pow(10, n)) / Math.pow(10, n);
}
exports.fixNumber = fixNumber;
